﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.ShprossesBuilder.Modelling.Components.Actions;
using System.Drawing;
using ITAP.ShprossesBuilder.Editor;
using ITAP.ShprossesBuilder.Modelling.Components;
using ITAP.ShprossesBuilder.Properties;

namespace ITAP.ShprossesBuilder.Operations
{
    class OperationAlignSelectedShprossConnectorsByDiamond : IOperation
    {
        public OperationAlignSelectedShprossConnectorsByDiamond()
        {
        }

        #region IOperation Members

        public string Name
        {
            get { return "Выравнивание соединителей по ромбу"; }
        }

        public void Execute(ModelControl modelControl)
        {
            DiamondAlignmentForm diamondForm = new DiamondAlignmentForm(false, false);

            if (diamondForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                RectangleF activeModelBoundingBox;
                if (modelControl.ModelContainer.ActiveCell != null)
                    activeModelBoundingBox = (modelControl.ModelContainer.ActiveCell as ModelCell).Model.BoundingBox;
                else
                    activeModelBoundingBox = RectangleF.Empty;

                IComponentAction diamondAction = new ActionSelectedShprossConnectorsDiamondAlignment(modelControl, diamondForm.Distance, diamondForm.DiamondAlignmentMeasure, activeModelBoundingBox);
                diamondAction.Action(null);
            }

        }

        #endregion

        #region IOperation Members


        public OperationGroup OperationGroup
        {
            get { return OperationGroup.ShprossConnectorOperation; }
        }

        #endregion

        #region IOperation Members


        public Image Thumbnail
        {
            get { return Resources.AlignShprossConnectorsByDiamond.ToBitmap(); }
        }

        #endregion

        #region IOperation Members


        public bool CanUndo
        {
            get { return true; }
        }

        #endregion
    }
}
